#include <GameEngine/UnitTest/unit_test.h>


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif


//! Launch all the unit tests
/*!
 @return True if all unit tests were succesful, false otherwise
 @note Unit tests are only run in debug mode. In release
       mode, this function always returns true. To have
       unit tests in both debug and release modes,
	   please use the force_test() function. 
 */
bool UnitTest::test() {
#ifdef _DEBUG
	return force_test();
#else
	return true;
#endif
}

//! Launch all the unit tests
/*!
 @return True if all unit tests were succesful, false otherwise
 */
bool UnitTest::force_test() {
	bool res = true;

	// AI library
	res &= test_ai_funnel_functions();

	// Core library
	res &= test_core_rtti_functions();
	res &= test_core_factory_functions();
	res &= test_core_graph_functions();
	res &= test_core_quadtree_functions();
	res &= test_core_octree_functions();

	// Maps library
	res &= test_maps_displacement_iterator_functions();

	// Geometry library
	res &= test_geometry_halfedge_trgl_mesh_functions();

	res &= test_geometry_angle_functions<float>();
	res &= test_geometry_angle_functions<double>();

	res &= test_geometry_box2d_functions<float>();
	res &= test_geometry_box2d_functions<double>();

	res &= test_geometry_box3d_functions<float>();
	res &= test_geometry_box3d_functions<double>();

	res &= test_geometry_circle2d_functions<float>();
	res &= test_geometry_circle2d_functions<double>();

	res &= test_geometry_circle3d_functions<float>();
	res &= test_geometry_circle3d_functions<double>();

	res &= test_geometry_hexagon2d_functions<float>();
	res &= test_geometry_hexagon2d_functions<double>();

	res &= test_geometry_line2d_functions<float>();
	res &= test_geometry_line2d_functions<double>();

	res &= test_geometry_line3d_functions<float>();
	res &= test_geometry_line3d_functions<double>();

	res &= test_geometry_sphere_functions<float>();
	res &= test_geometry_sphere_functions<double>();

	res &= test_geometry_trgl2d_functions<float>();
	res &= test_geometry_trgl2d_functions<double>();

	res &= test_geometry_trgl2dfast_functions<float>();
	res &= test_geometry_trgl2dfast_functions<double>();

	res &= test_geometry_trgl3d_functions<float>();
	res &= test_geometry_trgl3d_functions<double>();

	res &= test_geometry_trgl3dfast_functions<float>();
	res &= test_geometry_trgl3dfast_functions<double>();

	res &= test_geometry_transformer2d_functions<float>();
	res &= test_geometry_transformer2d_functions<double>();

	res &= test_geometry_transformer3d_functions<float>();
	res &= test_geometry_transformer3d_functions<double>();

	res &= test_geometry_transformer2d_orientation_functions<float>();
	res &= test_geometry_transformer2d_orientation_functions<double>();

	res &= test_geometry_transformer3d_orientation_functions<float>();
	res &= test_geometry_transformer3d_orientation_functions<double>();

#ifdef GAMEENGINE_VERBOSE_UNIT_TESTS
	if ( res == true ) std::cout << "[Unit tests] OK" << std::endl;
	else std::cerr << "[Unit tests] Failure" << std::endl;
#endif

	return res;
}


#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif
